app.controller("chapterLabelController", function ($scope, $controller, $location, chapterLabelService) {
    $controller('baseController', {$scope: $scope, baseService: chapterLabelService});

    $scope.del = function (id) {
        if (window.confirm("确认删除吗？")) {
            chapterLabelService.del({entity: {id: id}}).success(function (res) {
                $scope.resHandler(res, function (res) {
                    alert("删除成功");
                    $scope.findPage();
                })
            })
        }

    }

    $scope.batchDel = function () {
        if (window.confirm("确认删除吗")) {
            var queryJson = {
                ids: $scope.ids
            };
            chapterLabelService.batchDel(queryJson).success(function (res) {
                $scope.resHandler(res, function (res) {
                    alert("删除成功");
                    $('.js_checkbox').prop("checked", false);
                    $scope.ids = [];
                    $scope.findPage();
                })
            })
        }

    }

    $scope.edit = function () {
        var entity = $scope.entity;
        if (entity.name === undefined || entity.name === null) {
            alert("请输入名称");
            return;
        }
        chapterLabelService.edit({entity: entity}).success(function (res) {
            $scope.resHandler(res, function (res) {
                $scope.entity = {};
                $scope.findPage();
            })
        })
    }

    $scope.setOption=function(option, entity){
        $scope.option = option;
        if(entity !== undefined){
            $scope.entity = JSON.parse(JSON.stringify(entity));
        } else {
            $scope.entity = {};
        }
    }

    $scope.listInit = function () {
        $params = $location.search();
        $scope.findPage();
    }
});
